//
//  HTSplitViewController.m
//  Common
//
//  Created by 郝涛 on 16/5/16.
//  Copyright © 2016年 郝涛. All rights reserved.
//

#import "HTSplitViewController.h"

@interface HTSplitViewController ()

@end

@implementation HTSplitViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    /*
     UISplitViewControllerDisplayModeAutomatic, 自动默认设置方法
     UISplitViewControllerDisplayModePrimaryHidden, 主视图都隐藏 点击时间可以让他出来
     UISplitViewControllerDisplayModeAllVisible, 主视图控制器始终显示.点击无效
     UISplitViewControllerDisplayModePrimaryOverlay,主视图控制器悬浮，点击时间可以响应
     */
    self.preferredDisplayMode = UISplitViewControllerDisplayModeAllVisible;
    //主视图占据的比例数
    self.preferredPrimaryColumnWidthFraction = 0.5;
    
    //发送通知
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(UIDeviceOrientationDidChangeNotification) name:UIDeviceOrientationDidChangeNotification object:nil];
    
  
}
//接收通知  监听横竖屏变化
-(void)UIDeviceOrientationDidChangeNotification{
    //判断横屏竖屏
    if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) {
        //设置主视图最大宽度
        self.maximumPrimaryColumnWidth = 60;
    }else{
        //设置主视图最大宽度
        self.maximumPrimaryColumnWidth = 200;
    }
    
}
//
- (void)traitCollectionDidChange:(nullable UITraitCollection *)previousTraitCollection
{
    if (self.traitCollection.verticalSizeClass == UIUserInterfaceSizeClassRegular && self.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact) {
        NSLog(@"分屏");
    }else{
        NSLog(@"没有分屏");
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
